package com.challenge.smsdao.majormanage.domain;

import com.challenge.smsdao.studentmanage.domain.Grade;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.challenge.smsbase.Domain.BaseEntity;

import javax.persistence.*;
import java.util.List;

/**
 * luhongyu
 */
@Entity
public class Major extends BaseEntity<Long> {

    @Column
    private String name;
    @JsonIgnoreProperties("majors")
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "academy_id")
    private Academy academy;

    @JsonIgnoreProperties("major")
    @OneToMany(mappedBy = "major",cascade = {CascadeType.REMOVE,CascadeType.REFRESH},fetch = FetchType.LAZY)
    private List<Grade> grades;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Academy getAcademy() {
        return academy;
    }

    public void setAcademy(Academy academy) {
        this.academy = academy;
    }

    public List<Grade> getGrades() {
        return grades;
    }

    public void setGrades(List<Grade> grades) {
        this.grades = grades;
    }
}
